]> dgit.raspbian.org Git - pcre2.git/commit
Backport of pcre2-10.48-Fix-allocation-byte-sizing.patch
authorIlia Alshanetsky <ilia@ilia.ws>
Sun, 9 Aug 2026 11:15:03 +0000 (07:15 -0400)
committerMatthew Vernon <matthew@debian.org>
Tue, 1 Sep 2026 10:43:48 +0000 (11:43 +0100)
commitf66cb6b6f33c952570c4586ceaefb10736aa915d
treef926a9ec0975f233f515ca91a561614e4889ca3d
parent9bb46b0994e498d09460d44f09fbcd0021ced0db
Backport of pcre2-10.48-Fix-allocation-byte-sizing.patch

Cherry-pick of 8156b3989a82f2ddf9504d8248496e9b124be7f3

Use CU2BYTES for byte sizing in two allocation sites (#909)

Two allocation sites multiplied by PCRE2_CODE_UNIT_WIDTH (the bit width:
8, 16, or 32) where the CU2BYTES(x) byte-count helper is intended. The
result over-allocates by the code-unit byte width: 8x in 8-bit mode, 16x
in 16-bit, 32x in 32-bit. Subsequent memcpy calls already use CU2BYTES
correctly, so no out-of-bounds write occurs; the over-allocation is
leaked until the buffer is freed.

Also guard each site against integer overflow in
sizeof(pcre2_memctl) + CU2BYTES(N + 1) by rejecting N greater than
(PCRE2_SIZE_MAX - sizeof(pcre2_memctl)) / CU2BYTES(1) - 1.

(cherry picked from commit 31ec59526d641b85108c726fe201effc5dca8627)
src/pcre2_convert.c
src/pcre2_substring.c